/*
 *  $Id: TwilightShadows.cs 1051 2010-05-18 22:10:41Z thenn.erannor $
 *	This file is a part of Ragima CCG.
 *	(C) 2008 Ragima development group.
 *
 *	Licensed under the terms of the GNU GPL License version 2.
 *
 */

namespace Ragima.Cards001.Darkness.Spells {
    public class TwilightShadows: SelfEnchantmentCard {
        public TwilightShadows(): base("001_d_s_twilight_shadows") {
            Level = CompleteLevel.ReadyForTest;
            Element = ElementType.Darkness;
            Value = 100;
            AddManaCost(ElementType.Darkness, 1);
        }

        protected override EnchantmentAffect CreateEnchantment() {
            return new TwilightShadowsAffect();
        }

        private class TwilightShadowsAffect: EnchantmentAffect<TwilightShadows> {
            public override void SetAffect() {
                base.SetAffect();
                GlobalSummary.OnDeath += DoDeath;
                EnemySummary.OnDeath += DoDeath;
            }
            public override void ResetAffect() {
                base.ResetAffect();
                GlobalSummary.OnDeath -= DoDeath;
                EnemySummary.OnDeath -= DoDeath;
            }

            private void DoDeath(AbstractObject obj) {
                Creature cr = obj as Creature;
                if (cr != null && cr.PlaceAfterDeath == CardPlace.Grave)
                    Owner.Owner.IncrementMana(ElementType.Darkness, 1);
            }
        }
    }
}
